<template>
	<view class="container">
		<Header :isBack="true">
			<block slot="content">{{title}}</block>
		</Header>

		<view class="option-content">
			<text class="option-content-text">请描述您的问题</text>
			<textarea placeholder="请描述您的问题" v-model="description"
				style="display:inline-block;font-size: 30rpx;border: 1px solid #eee;padding:6rpx;width: 100%;background-color: #f2f2f2;" />

			<view class="bottom" @tap="clickConfirm">提交</view>
		</view>

	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {

		data() {
			return {
				title: '意见反馈',
				description: ''
			};
		},
		components: {

		},
		// computed: {
		// 	...mapState(['hasLogin']),
		// },
		async onLoad() {
			this.cate = uni.getStorageSync('cate')
		},
		methods: {
			// 触发提交表单
			async clickConfirm() {
				//判断是否登录
				let result = this.$api.isLogin();
				if (result === false) {
					return false;
				}

				if (!this.description) {
					this.$api.msg('请输入意见内容！');
					return false;
				}
				let token = uni.getStorageSync('token')
				let dataObj = {
					cate: this.cate,
					token: token,
					description: this.description
				};
				this.submit(dataObj);
			},

			//登录提交
			async submit(dataObj) {
				let res = await this.$myRequest({
					url: '/addOpinion',
					data: dataObj,
					methods: 'post'
				})

				if (res.data.status == 1) {
					this.$api.msg('提交成功', 'success', 1000);
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages6/pages/my/my'
						})
					}, 1000)
				} else {
					this.$api.msg(res.data.msg);
				}
			},
		},
	}
</script>
<style>
	page {
		background-color: #f7f7f7;
		font-size: $font-base;
	}
</style>
<style lang="scss" scoped>
	.option-content {
		// #ifdef APP-PLUS
		padding: 176rpx 50rpx;
		// #endif
		
		// #ifdef H5
		padding: 124rpx 50rpx;
		// #endif
		
		font-size: $font-base;

		.option-content-text {
			height: 56rpx;
			line-height: 56rpx;
			// font-weight: bold;
		}
	}

	.bottom {
		margin-top: 30rpx;
		border-radius: 10rpx;
		width: 100%;
		background-color: #f3431a;
		color: #fff;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
